package com.ljt.kotlinandmvvm.orderfrom.activity

import android.view.View
import androidx.core.content.ContextCompat
import com.ljt.base.activity.BaseActivity
import com.ljt.kotlinandmvvm.R
import com.ljt.kotlinandmvvm.databinding.ActivityOrderFromBinding
import com.ljt.kotlinandmvvm.orderfrom.adapter.OrderFromViewPagerAdapter
import kotlinx.android.synthetic.main.draw_module_title.view.*

/**
 * @auther :lujiantao
 * @date :2024/5/5 2:53 PM
 * @desc :
 */
class OrderFromActivity: BaseActivity<ActivityOrderFromBinding, OrderFromViewModel>(),
    View.OnClickListener {

    private lateinit var adapter:OrderFromViewPagerAdapter

    override fun getLayoutResId(): Int {
        return R.layout.activity_order_from
    }

    override fun createViewModel(): OrderFromViewModel {
        return OrderFromViewModel()
    }

    override fun initView() {
        if (binding != null) {
            binding.ilModuleTitle.tvModuleTitle.text = "我的订单"
            binding.ilModuleTitle.ivModuleBack.setOnClickListener(this)
        }
    }

    override fun initData() {
        adapter = OrderFromViewPagerAdapter(supportFragmentManager)
        binding.vpModule.adapter = adapter
        binding.tlModule.setupWithViewPager(binding.vpModule)
        binding.tlModule.setTabTextColors(
            ContextCompat.getColor(this, R.color.sp_666), // 未选中颜色
            ContextCompat.getColor(this, R.color.orange)    // 选中颜色
        )
        binding.tlModule.setSelectedTabIndicatorColor(ContextCompat.getColor(this,R.color.orange))

        var index = intent.getIntExtra("module_type",0)
        binding.vpModule.currentItem = index
    }

    override fun onClick(v: View?) {
        var id = v?.id
        if (id == R.id.ivModuleBack){
            finish()
        }
    }
}